package exteditapp.state;

import exteditapp.AppletIterator;
import exteditapp.FileDefault;
import exteditapp.action.ActionUnlocking;
import exteditapp.command.CommandUnlock;

/**
 * State - file idle or not changed (instantiated then last edit was N seconds ago)
 * @author Arturas Smorgun, arturas@smorgun.lt
 */
public class StateUnlocking extends IState {

	/**
	 * Default constructor
	 * @param iterator is system iterator, which performs all actions
	 * @param file this is file, which state we will hold
	 */
	public StateUnlocking(AppletIterator iterator, FileDefault file) {
		super(iterator, file);
		start();
	}
	public StateUnlocking(AppletIterator iterator, FileDefault file, boolean doRegister){
		super(iterator, file, doRegister);
		start();
	}
	
	protected void start(){
		this.setAction(new ActionUnlocking());
		//TODO implement state
		System.out.println("Before lock");
		this.file.getModule().getInvoker().execute(new CommandUnlock(this.file));	
		System.out.println("After lock");
	}
	
	/**
	 * Handling of new state
	 */
	public boolean handle() {
		//TODO implement idle state handling
		return false;
	}
	
}
